//
//  LoginCenterView.m
//  SinaWeibo
//
//  Created by Apple on 16/8/11.
//  Copyright © 2016年 Apple. All rights reserved.
//

#import "LoginCenterView.h"

@interface LoginCenterView()

@property (weak, nonatomic) IBOutlet UIImageView *houseImage;


@property (weak, nonatomic) IBOutlet UILabel *infoLabel;

@property (strong, nonatomic) CADisplayLink *displayLink;


@end



@implementation LoginCenterView

/**
 *  懒加载定时器
 */
-(CADisplayLink *)displayLink{
    
    if (_displayLink == nil) {
        _displayLink = [CADisplayLink displayLinkWithTarget:self selector:@selector(rotate)];
    }
    return _displayLink;
}


+(instancetype)defaultCenterView{
    
    LoginCenterView *defaultCenterView = [[NSBundle mainBundle] loadNibNamed:@"LoginCenterView" owner:nil options:nil].lastObject;
    
    defaultCenterView.iconImageName = @"visitordiscover_feed_image_smallicon";
    
    defaultCenterView.info = @"当你关注一些人以后，他们发布的最新消息会显示在这里";
    
    return defaultCenterView;
}

-(void)setIconImageName:(NSString *)iconImageName{
    
    _iconImageName = iconImageName;
    
    self.houseImage.image = [UIImage imageNamed:iconImageName];
    
}


-(void)setInfo:(NSString *)info{
    _info = info;
    
    self.infoLabel.text = info;
}


/**
 *  转动转盘
 */
-(void)starRotate{
    
//    CADisplayLink *displayLink = [CADisplayLink displayLinkWithTarget:self selector:@selector(rotate)];
    
//    self.displayLink = displayLink;
    
    [self.displayLink addToRunLoop:[NSRunLoop mainRunLoop] forMode:NSRunLoopCommonModes];
    
}

-(void)stopRotate{
    [self.displayLink invalidate];
    self.displayLink = nil;
}



-(void)rotate{
    
    self.trunkImage.transform = CGAffineTransformRotate(self.trunkImage.transform, M_PI/320);
    
}


#pragma mark - cilckRegister

- (IBAction)clickRegister:(UIButton *)sender {
    
    if ([self.delegate respondsToSelector:@selector(loginCenterView:clickRegister:)]) {
        [self.delegate loginCenterView:self clickRegister:sender];
    }
    
}


#pragma mark - clickLogin

- (IBAction)clickLogin:(UIButton *)sender {
    
    if ([self.delegate respondsToSelector:@selector(loginCenterView:clickLogin:)]) {
        [self.delegate loginCenterView:self clickLogin:sender];
    }
    
}












@end
